<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Switch 语句</title>
</head>

<body>
    <script>
        //1.switch语句也是多分支语句，
        //
        switch (2) {
            case 1:
                console.log('This is 1');
                break;
            case 2:
                console.log('This is 2');
                break;
            case 3:
                console.log('This is 3');
                break;
            default:
                console.log('NULL');

        }

        // switch 注意事项
        var num = 3;
        switch (num) {
            case 1:
                console.log(1);
                break; // 最好写，因为匹配执行完后结束，不写会继续执行下一个case
            case 2:
                console.log(2);
                break;
            case 3:
                console.log(3);
                break;

        }
        //1.switch 表达式通常写成变量
        //2.num里的值和case 里面的值相匹配的时候时是 全等 必须是值和数据类型一致才可以 num === 1
        //3.break 如果当前的case里面没有break 则不会退出switch 而是继续执行下一个case
    </script>
</body>

</html>